/*
 * $Id: FileUploadBean.java,v 1.9 2012/02/01 20:01:10 navdeep_mahajan Exp $
 * 
 * Copyright (C) 2008 General Electric Company. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 * 
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */
package com.ge.healthcare.autosc.onwatch.bean;

import org.springframework.web.multipart.MultipartFile;

import com.ge.healthcare.autosc.onwatch.util.OnWatchConstants;


/**
 * Java bean for Onwatch file upload
 * @author 212042946
 *
 */
public class FileUploadBean extends BaseInfoBean {

	public static final long serialVersionUID = 0L;
	
	private String createDate = null;
	private String createdBy = null;
	private String serviceId = null;
	private String serviceDate = null;
	private String fileSize = null;
	private String checksum = null;
	private boolean lastAttempt = true;
	private String filename = null;
	private MultipartFile file;
	
	public FileUploadBean() {
		super();
	}
	
	public String getCreateDate() {
		return createDate;
	}
	
	public void setCreateDate(String createDate) {
		this.createDate = createDate;
	}
	
	public String getCreatedBy() {
		return createdBy;
	}
	
	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}
	
	public String getServiceId() {
		return serviceId;
	}
	
	public void setServiceId(String serviceId) {
		this.serviceId = serviceId;
	}
	
	public String getServiceDate() {
		return serviceDate;
	}
	
	public void setServiceDate(String serviceDate) {
		this.serviceDate = serviceDate;
	}
	
	public String getFileSize() {
		return fileSize;
	}
	
	public void setFileSize(String fileSize) {
		this.fileSize = fileSize;
	}
	
	public void setFile(MultipartFile file) {
        this.file = file;
    }

    public MultipartFile getFile() {
        return file;
    }
    
    public boolean isProdiagsRequest() {
    	return (OnWatchConstants.PRODIAGS_REQUEST_TYPE.equalsIgnoreCase(getRequestType()));
    }

    public boolean isStatusReportRequest() {
    	return (OnWatchConstants.STATUSREPORT_REQUEST_TYPE.equalsIgnoreCase(getRequestType()));
    }

	public String getChecksum() {
		return checksum;
	}

	public void setChecksum(String checksum) {
		this.checksum = checksum;
	}

	public boolean isLastAttempt() {
		return lastAttempt;
	}

	public void setLastAttempt(boolean lastAttempt) {
		this.lastAttempt = lastAttempt;
	}
	
	public void setLastAttempt(String lastAttempt) {
		if("false".equalsIgnoreCase(lastAttempt)) {
			setLastAttempt(false);
		} else {
			setLastAttempt(true);
		}
	}
	
	public String toString() {
		StringBuffer str = new StringBuffer();
		str.append(super.toString()).append(",");
		str.append("{createDate: ").append(getCreateDate()).append("},");
		str.append("{createdBy: ").append(getCreatedBy()).append("},");
		str.append("{serviceId: ").append(getServiceId()).append("},");
		str.append("{serviceDate: ").append(getServiceId()).append("},");
		str.append("{fileSize: ").append(getFileSize()).append("},");
		str.append("{checksum: ").append(getChecksum()).append("},");
		str.append("{lastAttempt: ").append((isLastAttempt()?"true":"false")).append("},");
		str.append("{filename: ").append(getFilename()).append("},");
		str.append("{upload file name: ").append(getFile()!=null?getFile().getOriginalFilename():null).append("}");
		return str.toString();
	}

	/**
	 * @return the filename
	 */
	public String getFilename() {
		return filename;
	}

	/**
	 * @param filename the filename to set
	 */
	public void setFilename(String filename) {
		this.filename = filename;
	}
}
